Skip to content

Conversation

@sofiaromorales
Copy link
Contributor

@sofiaromorales sofiaromorales commented Oct 18, 2024

Bug/issue #, if applicable: 139722227

Summary

DocC current logic for determining API availability involves adding the symbol graphs operating system platform name to the final symbol availability.

This approach is problematic because the platform name may not always be in a human-readable format. While it's necessary for calculating availability, we don't want it included as an explicit availability item.

This is a major refactor of the availability logic to not include the symbolgraph operating system platform name as an availability item.

Dependencies

Describe any dependencies this PR might have, such as an associated branch in another repository.

Testing

Review unit tests added.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary

Copy link
Contributor

@d-ronnqvist d-ronnqvist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a great step towards making this complex logic both more correct and easier to read.

This refactor was initiated by the need of stop using the module operating system name as an availability item.

This change required a big refactoring of the logic, and now the symbol graph availability loading logic is like the following:
1. Every symbol graph is loaded and the symbols get only the availability information that's marked in the SDK.
2. Once all the SGFs are oaded, whe iterate over the symbols and we add the fallbkac and default availability if applies.
@sofiaromorales sofiaromorales force-pushed the fix-availability-logic-refactor branch from 61e6e1e to ec28dd5 Compare November 11, 2024 11:57
Instead of making a `[(FallbackPlatform, InheritedPlaform)].
The new struture to hold this information is in the way of `[InheritedPlatfor:[FallbackPlatforms]]`.
@sofiaromorales sofiaromorales marked this pull request as ready for review November 12, 2024 16:02
Comment on lines +289 to +291
guard symbolsByPlatformName[defaultAvailability.platformName.rawValue]?.contains(where: {
symbolID == $0.precise
}) != false else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: AFAICT this is the only place that uses symbolsByPlatformName. If that's correct, maybe it would be worth using a set of symbol IDs so that this can use contains(_:) instead of contains(where:).

In other words, changing symbolsByPlatformName from [String: [SymbolGraph.Symbol.Identifier]] to [String: Set]

Copy link
Contributor

@d-ronnqvist d-ronnqvist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like good improvements to me.

I left a few very minor suggestions but nothing blocking.

@sofiaromorales
Copy link
Contributor Author

@swift-ci please test

@sofiaromorales
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@sofiaromorales
Copy link
Contributor Author

@swift-ci please test

@sofiaromorales
Copy link
Contributor Author

@swift-ci please test

@sofiaromorales sofiaromorales merged commit 1ad9b6a into swiftlang:main Jan 29, 2025
2 checks passed
sofiaromorales added a commit to sofiaromorales/swift-docc that referenced this pull request Jan 31, 2025
sofiaromorales added a commit that referenced this pull request Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants